# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 存放api接口信息。以dict形式存放，这样就可以API_ALL[''][url]这种方式去取，看起来较直观，知道取得是哪个接口的那部分信息
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import json

# 接口响应
API_response={
    "pay_SH": {
        "document":{
            "body":{
                "Signature":"Zjs3UHAdKiBn2puB8X3Lb+hVGBaxs8YokdntIUbhz2EX4P1LOQVkKCw==",
                "bizDate":"20230719",
                "borrowNum":"4872",
                "cleanDate":"20200416",
                "paymentMethod":"CEQ",
                "period":24,
                "punishRate":0.207236,
                "repayInfoRec":[
                    {
                    "loanPeriod":"1",
                    "repayAmt":51.25,
                    "repayBal":33.98,
                    "repayBeginDate":"20230802",
                    "repayEndDate":"20230805",
                    "repayFee":0.0,
                    "repayInte":17.27
                },
                {
                    "loanPeriod":"24",
                    "repayAmt":51.25,
                    "repayBal":50.37,
                    "repayBeginDate":"20250702",
                    "repayEndDate":"20250705",
                    "repayFee":0.0,
                    "repayInte":0.88
                }
            ],
                "settleResult":"",
                "settleStatus":"",
                "stageRate":0.207236,
                "txnAmt":1000.0,
                "txnResult":"交易成功",
                "txnStatus":"S"
            },
            "head":{
                "HeadBusinessId":"202004161108079woN3L81Xr8uehZuOp",
                "HeadMsgVersion":"1.0",
                "HeadRetCode":"000000",
                "HeadRetMsg":"交易成功",
                "HeadRevOrgan":"SHBANK",
                "HeadRspDate":"20200416",
                "HeadRspTime":"110816",
                "HeadSndOrgan":"RENDONG",
                "HeadTranCode":"IBPS_LM_112006"
            }
        }
    },
    # 上海银行：125007提前还款试算接口（调用）-提前结清、退货
    "pre_repayTrial_SH": {
        "document":{
            "body":{
                "Signature":"BQFhXOwFWjWGl/FFVwITJ2KkBNNA4MQ==",
                "bizDate":"20221223",
                "borrowNo":"4334",          # 资金方借据号: provider_loan.acct_seq_no
                "refundAmt":1000.58,        # 还款总金额
                "refundFee":0,              # 还款费用
                "refundInte":0.58,          # 还款利息
                "refundPay":1000.0          # 还款本金
            },
            "head":{
                "HeadRetCode":"000000",
                "HeadRetMsg":"交易成功"
            }
        }
    },

}


if __name__ == '__main__':
    # json indent=缩进空格数,得到树型格式; ensure_ascii=False,不希望中文字符等被unicode转义; sort_keys=True,希望显示的字典内的字段是排过序的
    data = json.dumps(API_response['pre_repayTrial_SH'],indent=4,ensure_ascii=False)
    print(data)